package o;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import org.json.JSONException;
import org.json.JSONObject;

public class cyl {
    private final int ˊ;
    private final String ˋ;
    private final SharedPreferences ˏ;
    private final int ॱ;

    private cyl(Context context) {
        this.ˏ = context.getSharedPreferences("com.huawei.appgallery.shortcutmanager.data", 0);
        this.ˊ = cyh.ˊ(context);
        this.ॱ = cyh.ˎ(context);
        this.ˋ = cyh.ॱ(context);
    }

    public static cyl ˋ(Context context) {
        if (context != null) {
            return new cyl(context.getApplicationContext());
        }
        throw new NullPointerException("context must not be null.");
    }

    public void ˎ(String str) {
        ˊ(str, true);
    }

    public void ˊ(String str, boolean z) {
        Object jSONObject;
        try {
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("not_remind", z);
            jSONObject2.put("app_version", this.ˊ);
            jSONObject2.put("simpleui_mode", this.ॱ);
            jSONObject2.put("launcher_package_name", this.ˋ);
            jSONObject = jSONObject2.toString();
        } catch (JSONException e) {
            jSONObject = "";
        }
        if (!TextUtils.isEmpty(jSONObject)) {
            this.ˏ.edit().putString(str, jSONObject).commit();
        }
    }

    public boolean ˊ(String str) {
        return ˎ(str, true);
    }

    public boolean ˎ(String str, boolean z) {
        boolean z2 = true;
        try {
            Object string = this.ˏ.getString(str, "");
            if (TextUtils.isEmpty(string)) {
                return false;
            }
            JSONObject jSONObject = new JSONObject(string);
            if (z) {
                if (!(jSONObject.getBoolean("not_remind") && jSONObject.getInt("app_version") / 1000 == this.ˊ / 1000 && jSONObject.getInt("simpleui_mode") == this.ॱ && cyh.ˋ(jSONObject.getString("launcher_package_name")).equals(this.ˋ))) {
                    z2 = false;
                }
                return z2;
            }
            if (!(jSONObject.getBoolean("not_remind") && jSONObject.getInt("simpleui_mode") == this.ॱ && cyh.ˋ(jSONObject.getString("launcher_package_name")).equals(this.ˋ))) {
                z2 = false;
            }
            return z2;
        } catch (ClassCastException e) {
            return false;
        } catch (JSONException e2) {
            return false;
        }
    }
}
